﻿using System;
using System.Collections.Generic;
using ATSIDAL;
using ATSModel;
using System.Data.SqlClient;
using System.Data;
namespace ATSDAL
{
    public class TCalibrationItem : BaseRepository<TCalRecordItemInfo>, ITCalibrationItem
    {
        private const String PRAM_Cali_InstrumentID = "@InstrumentID";
        private const String PRAM_Cali_RecordTime = "@RecordTime";

        public IList<TCalRecordItemInfo> LoadEntities()
         {
             return null;
         }

        public TCalRecordItemInfo LoadEntity<T1>(T1 Id)
         {
             return null;
         }
        public IList<TCalRecordItemInfo> GetTestItems(string InstrumentID, DateTime testTime)
        {
            SqlParameter[] testItemParms = GetSNTParameters();
            //Bind the parameter
            testItemParms[0].Value = InstrumentID;
            testItemParms[1].Value = testTime;
            return ExcuteSqlToGetEntities("CalRecordItem_select_SNDT", testItemParms);
        }
        //函数内部调用函数
        private static SqlParameter[] GetSNTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PRAM_Cali_InstrumentID, SqlDbType.NVarChar, 50),
					new SqlParameter(PRAM_Cali_RecordTime, SqlDbType.DateTime, 8)                
                };
            return parms;
        }
        //重写超类基础操作
        public override TCalRecordItemInfo GetEntityRecord(SqlDataReader rdr)
        {
            TCalRecordItemInfo pro = new TCalRecordItemInfo
            {
                InstrumentID = rdr.GetValue(0).ToString(),
                RecordTime = rdr.GetDateTime(1),
                Port = rdr.GetValue(2).ToString(),
                PortIndex = rdr.GetValue(3).ToString(),
                Band = rdr.GetValue(4).ToString(),
                ValueType =rdr.GetValue(5).ToString(),
                Value = rdr.GetValue(6).ToString(),
                Spec = rdr.GetValue(7).ToString(),
                IsPass = rdr.GetValue(8).ToString()
            
            };
            return pro;
        }
    }

}
